package org.micode.demo.web.controller;

import org.micode.common.helper.I18nMsgHelper;
import org.micode.demo.web.base.BaseWebAdminController;
import org.micode.common.annotation.NoNeedLogin;
import org.micode.common.domain.ApiResult;
import org.micode.demo.biz.service.BizConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/web-admin/config")
public class ConfigController extends BaseWebAdminController {

    @Autowired
    private BizConfigService bizConfigService;

    @NoNeedLogin
    @PostMapping("/reloadConfig")
    public ApiResult<Boolean> reloadConfig() {
        log.debug(I18nMsgHelper.get("api.call.config.reloadConfig"));
        String clientIp = getLoginClientIp();
        Boolean ret = bizConfigService.reloadConfig(clientIp);
        return doReturnSuccess(ret);
    }

}
